Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
@babel/plugin-transform-spread
Advanced tools
The @babel/plugin-transform-spread npm package is a plugin for Babel, a JavaScript compiler, that transforms spread properties in object literals and spread elements in array literals into a form that can be understood by environments that do not support the spread syntax. This transformation ensures compatibility with older browsers or JavaScript environments.
Object Spread
Transforms spread properties in object literals to use Object.assign, enabling the combination of multiple objects into one.
{"const obj1 = { a: 1, b: 2 };\nconst obj2 = { ...obj1, c: 3 };\n// Transformed to:\n// const obj2 = Object.assign({}, obj1, { c: 3 });"}
Array Spread
Transforms spread elements in array literals to use Array.concat, allowing the creation of new arrays by combining or adding elements.
{"const arr1 = [1, 2];\nconst arr2 = [...arr1, 3, 4];\n// Transformed to:\n// const arr2 = arr1.concat([3, 4]);"}
This package provides functionality similar to @babel/plugin-transform-spread but focuses on both spreading of elements and the rest properties for object destructuring assignment and spread properties for object literals. It's a more comprehensive solution for handling spread and rest properties in modern JavaScript.
While not a direct alternative, core-js includes polyfills for many ECMAScript features, including the spread syntax. It allows developers to use spread syntax in environments that do not natively support it by providing the necessary polyfills.
Compile ES2015 spread to ES5
See our website @babel/plugin-transform-spread for more information.
Using npm:
npm install --save-dev @babel/plugin-transform-spread
or using yarn:
yarn add @babel/plugin-transform-spread --dev
v7.25.7 (2024-10-02)
babel-helper-validator-identifier
babel-traverse
babel-plugin-transform-classes
super()
check (@nicolo-ribaudo)babel-generator
infer
in compact mode (@nicolo-ribaudo)[no LineTerminator here]
after nodes (@nicolo-ribaudo)babel-types
babel-core
--experimental-require-module
(@nicolo-ribaudo)babel-helper-compilation-targets
, babel-helper-plugin-utils
, babel-preset-env
babel-plugin-proposal-destructuring-private
, babel-plugin-syntax-decimal
, babel-plugin-syntax-import-reflection
, babel-standalone
babel-generator
[no LineTerminator here]
before nodes (@nicolo-ribaudo)babel-plugin-transform-typescript
babel-types
BABEL_TYPES_8_BREAKING
at startup (@nicolo-ribaudo)FAQs
Compile ES2015 spread to ES5
We found that @babel/plugin-transform-spread demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.